package com.example.wifiunlockscreen.support;

import java.util.List;

import com.example.wifiunlockscreen.R;
import com.example.wifiunlockscreen.listeners.CLickDeleteWifiFriend;
import com.example.wifiunlockscreen.listeners.ClickShowWifiFriendListListener;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;

public class WifiFriendListAdapter extends BaseAdapter {

	private final Activity actividad;
	private final List<WifiFriendObject> lista;
	private final WifiInfoManager wifiInfoManager;
	
	public WifiFriendListAdapter(Activity actividad, List<WifiFriendObject> lista, WifiInfoManager wifiInfo){
		this.actividad=actividad;
		this.lista=lista;
		this.wifiInfoManager = wifiInfo;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		
		/*
	    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    
	    View rowView = inflater.inflate(R.layout.rowlayout, parent, false);
	    
	    TextView textView = (TextView) rowView.findViewById(R.id.label);
	    
	    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
	    
	    textView.setText(values[position]);
	    
	        // change the icon for Windows and iPhone
	        String s = values[position];
	        if (s.startsWith("iPhone")) {
	          imageView.setImageResource(R.drawable.no);
	        } else {
	          imageView.setImageResource(R.drawable.ok);
	        }

	        return rowView;
		*/
		
         LayoutInflater inflater = actividad.getLayoutInflater();
         View view = inflater.inflate(R.layout.item_list_wifi_friend, null, true);
         TextView textView =(TextView)view.findViewById(R.id.wifi_name);
         textView.setText(lista.get(position).getNombre());
         
         CLickDeleteWifiFriend clickDeleteWIfiFriend = new CLickDeleteWifiFriend(lista.get(position), wifiInfoManager);
         
         ImageButton botonImagen = (ImageButton) view.findViewById(R.id.deleteButton);
         
         botonImagen.setOnClickListener(clickDeleteWIfiFriend);
         
         /*textView.setText(lista.elementAt(position));
         ImageView imageView=(ImageView)view.findViewById(R.id.icono);*/
		
		return view;
		
	}
	
	@Override
	public int getCount() {

		return lista.size();
	}

	@Override
	public Object getItem(int arg0) {
		
		return lista.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}


}
